package com.qdu.springboot01cache.service;

import com.qdu.springboot01cache.bean.Employee;
import com.qdu.springboot01cache.bean.EmployeeExample;
import com.qdu.springboot01cache.mapper.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService extends BaseService<Employee,EmployeeExample> {

    @Autowired
    private EmployeeMapper employeeMapper;

    //条件查询，查询指定姓名的第一个姓名员工
    public Employee selectByLastName(String lastname){
        EmployeeExample example = new EmployeeExample();
        example.createCriteria().andLastnameEqualTo(lastname);
        List<Employee> list = employeeMapper.selectByExample(example);
        System.out.println("查询的是名字为"+lastname+"的员工");
        return list.get(0);
    }
}
